<div id="opisPage">
    <div class="post">
        <h2 class="title">Organizational Performamce Index (OPI)</h2>
        <div class="entry">
            <input type="button" value="Add new" onclick="show('#new_opi')"/>

            <?php
            if ($this->session->userdata("admin")) {
            ?>
                <input type="button" value="Search" onclick="show('#searchOpis')"/>
                <input type="button" value="Clear Search" onclick="clearSearch()"/>
            <?php
            }
            ?>
            <div id="opis_result" class="info">
                <?= $message ?>
            </div>
            <script type="text/javascript">
                function searchOpis(num){
                    field=document.getElementById("searchOpisForm"+num).field.value;
                    search=document.getElementById("searchOpisForm"+num).search.value;
                    $("#opisPage").load("<?= base_url(); ?>index.php?/admin_mis/opis/"+field+"/"+search);
                }
                function clearSearch(){
                    $("#opisPage").load("<?= base_url(); ?>index.php?/admin_mis/opis/");
                }
            </script>
        </div>
        <script>
            $(function() {
                $( "#opi_datepicker" ).datepicker({ dateFormat: 'yy-mm-dd' });
            });
        </script>
        <!--a href="" id="hide3" >Hide</a> <a href="" id="show3" >Show</a-->
        <div id="new_opi" style="display: none;margin-bottom: 10px;">
            <?php $data['id'] = "opi_form" ?>
            <?= form_open_multipart('mis/saveOpi', $data); ?>
                <table>
                    <tr class="darker"><td class="half">Company Name</td><td>
                            <select name="company_name">
                            <?php foreach ($clients as $type): ?>
                                <option value="<?= $type->tid; ?>"><?= $type->name; ?></option>
                            <?php endforeach; ?>
                            </select></td> </tr>
                    <tr class="lighter"><td class="half">Business Type</td><td>
                            <select name="business_type">
                            <?php foreach ($bus_types as $type): ?>
                                    <option value="<?= $type->tid; ?>"><?= $type->name; ?></option>
                            <?php endforeach; ?>
                                </select></td> </tr>
                        <tr class="darker"><td class="half">Relationship Manager</td><td><input type="text" class="wide" name="relations_mgr" value="<?php echo set_value('relations_mgr'); ?>" /></td> </tr>
                        <tr class="lighter"><td class="half">Award won</td><td><input type="text" class="wide" name="awards_won" value="<?php echo set_value('awards_won'); ?>" /></td> </tr>
                        <tr class="darker"><td class="half">Year Assessed</td><td><input type="text" class="wide" name="yr_assessed" value="<?php echo set_value('yr_assessed'); ?>" /></td> </tr>
                        <tr class="lighter"><td class="half">No. Of Champions Trained</td><td><input type="text" class="wide" name="champions_trained" value="<?php echo set_value('champions_trained'); ?>" /></td> </tr>
                        <tr class="darker"><td class="half">Training Year</td><td><input type="text" class="wide" name="training_yr" value="<?php echo set_value('training_yr'); ?>" /></td> </tr>

                        <tr><td colspan="2" style="text-align: right">
                                <input type="submit" value="Submit" />
                                <input type="button" value="Cancel" onclick="hide('#new_opi')"/>
                            </td></tr>
                    </table>
                    </form>
                </div>

                <div id="searchOpis" style="display: none;margin-bottom: 10px;">
                    <form id="searchOpisForm1">

                        <input type="hidden" name="field" value="company_name"/>
                        <table>
                            <tr class="darker"><td class="half">Search by company</td>
                                <td><select name="search">
                                <?php foreach ($clients as $type): ?>
                                        <option value="<?= $type->tid; ?>"><?= $type->name; ?></option>
                                <?php endforeach; ?>
                                    </select></td>
                            </tr>

                            <tr><td colspan="3" style="text-align: right">
                                    <input type="button" value="Submit" onclick="searchOpis(1)" />
                                    <input type="button" value="Cancel" onclick="hide('#searchOpis')"/>
                                </td></tr>

                        </table>
                    </form>

                    <form id="searchOpisForm2">

                        <input type="hidden" name="field" value="business_type"/>
                        <table>
                            <tr class="darker"><td class="half">Search by business type</td>
                                <td><select name="search">
                                <?php foreach ($bus_types as $type): ?>
                                            <option value="<?= $type->tid; ?>"><?= $type->name; ?></option>
                                <?php endforeach; ?>
                                        </select></td>
                                </tr>

                                <tr><td colspan="2" style="text-align: right">
                                        <input type="button" value="Submit" onclick="searchOpis(2)" />
                                        <input type="button" value="Cancel" onclick="hide('#searchOpis')"/>
                                    </td></tr>

                            </table>
                        </form>
                        <form id="searchOpisForm3">
                            <table>
                                <tr class="darker"><td class="half">Select search criteria</td>
                                    <td><select name="field">
                                            <option value="all">All</option>
                                            <option value="relations_mgr">Relationship manager</option>
                                            <option value="awards_won">Awards won</option>
                                            <option value="added_by">Added by</option>
                                        </select></td>
                                    <td><input type="text" name="search" class="wide"  value="<?php echo set_value('added_by'); ?>" /></td>

                                </tr>

                                <tr><td colspan="2" style="text-align: right">
                                        <input type="button" value="Submit" onclick="searchOpis(3)" />
                                        <input type="button" value="Cancel" onclick="hide('#searchOpis')"/>
                                    </td></tr>

                            </table>
                        </form>
                    </div>
                    <div id="all_opis">
            <?= $tablet ?>
            <?= $pagina ?>
        </div>

    </div>
</div>
</div>